<?php

namespace business\elasticsearch\types;

class NewsConfigType
{
    /**
     * 基础设置
     * @return array
     */
    public static function settingsConfig()
    {
        return [
            'index' => [
                'number_of_shards' => 5,
                'number_of_replicas' => 1,
                'analysis.analyzer.default.type' => 'ik_max_word',
            ]
        ];
    }

    /**
     * mapping配置
     * @return array
     */
    public static function mapConfig()
    {
        return [
            'properties' => [
                'uid' => [
                    'type'        => 'text',
                    'fields'      => [
                        'keyword' => [
                            'ignore_above' => 256,
                            'type'         => 'keyword'
                        ]
                    ]
                ], //主键id
                'title' => [
                    'type'         => 'text',
                    'fields'       => [
                        'keyword'  => [
                            'ignore_above' => 256,
                            'type' => 'keyword'
                        ]
                    ]
                ],  //资讯标题
                'categoryId' => [
                    'type'         => 'text',
                    'fields'       => [
                        'keyword'  => [
                            'ignore_above' => 256,
                            'type' => 'keyword'
                        ]
                    ]
                ], //分类ID
                'categoryName' => [
                    'type'         => 'text',
                    'fields'       => [
                        'keyword'  => [
                            'ignore_above' => 256,
                            'type' => 'keyword'
                        ]
                    ]
                ],   //分类名称
                'author' => [
                    'type'         => 'text',
                    'fields'       => [
                        'keyword'  => [
                            'ignore_above' => 256,
                            'type' => 'keyword'
                        ]
                    ]
                ], //作者
                'tag' => [
                    'type'         => 'text',
                    'fields'       => [
                        'keyword'  => [
                            'ignore_above' => 256,
                            'type' => 'keyword'
                        ]
                    ]
                ], //标签
                'digest' => [
                    'type'         => 'text',
                    'fields'       => [
                        'keyword'  => [
                            'ignore_above' => 256,
                            'type' => 'keyword'
                        ]
                    ]
                ], //摘要
                'imgSrc' => [
                    'type'         => 'text',
                    'fields'       => [
                        'keyword'  => [
                            'ignore_above' => 256,
                            'type' => 'keyword'
                        ]
                    ]
                ], //图片地址
                'content' => [
                    'type'         => 'text',
                    'fields'       => [
                        'keyword'  => [
                            'ignore_above' => 256,
                            'type' => 'keyword'
                        ]
                    ]
                ],    //文章内容
                'createdTime' => [
                    'type'         => 'date',
                    'format'       => 'yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis'
                ],    //创建时间
                'view' => ['type' => 'long'],   //查看次数
            ]
        ];

    }

}